import Request from '../common/js/request'

class FlowType {
  /**
   * 根据类型名称查询是否已被注册
   * @param typeName 类型名称
   * @param typeId 类型Id
   */
  static getIsExistsByTypeName(typeName, typeId) {
    const url = '/api-workflow/type/getIsExistsByTypeName'

    const data = {
      typeName,
      typeId
    }

    return Request.get(url, data)
  }

  /**
   * 根据类型名称查询类型列表
   * @param typeName 类型名称
   * @param pageNum 当前页数
   * @param pageSize 每页条数
   */
  static getTypeListByTypeName(typeName, pageNum, pageSize) {
    const url = '/api-workflow/type/getTypeListByTypeName'

    const data = {
      typeName,
      pageNum,
      pageSize
    }

    return Request.get(url, data)
  }

  /**
   * 获取所有类型列表
   */
  static getTypeListAll() {
    const url = '/api-workflow/type/getTypeListAll'

    return Request.get(url)
  }

  /**
   * 获取所有类型列表(包括流程定义信息)
   */
  static getTypeListAndProcessDefinitionAll() {
    const url = '/api-workflow/type/getTypeListAndProcessDefinitionAll'

    return Request.get(url)
  }

  /**
   * 添加类型
   * @param type 类型对象
   */
  static insertType(type) {
    const url = '/api-workflow/type/insertType'

    return Request.post(url, type)
  }

  /**
   * 更新类型
   * @param type 类型对象
   */
  static updateType(type) {
    const url = '/api-workflow/type/updateType'

    return Request.post(url, type)
  }

  /**
   * 删除类型
   * @param typeIds 类型Ids
   */
  static deleteTypes(typeIds) {
    const url = '/api-workflow/type/deleteTypes'

    const data = {
      typeIds: typeIds.toString()
    }

    return Request.post(url, data)
  }
}

export default FlowType
